// const autojsUtils = require('./modules/autojs-utils');
"ui";

auto();

/** 保持屏幕常亮 */
device.keepScreenOn();

/** 识别页面循环间隔阀值 */
const QUERY_TIMES = 20;

/** 医生名称缓存 */
const STORAGE_DOCTOR = "DOCTOR_NAME";
const KEY_DOCTOR_NAME = "DOCTOR_NAME";

const getDoctorName = () => {
    let storage = storages.create(STORAGE_DOCTOR);
    let name = storage.get(KEY_DOCTOR_NAME) || "";
    return name;
}

const setDoctorName = (newValue) => {
    mDoctorName = newValue || "";

    let storage = storages.create(STORAGE_DOCTOR);
    storage.put(KEY_DOCTOR_NAME, newValue + "");
}

ui.layout(
    <vertical>
        <input id="doctor"
            marginTop="16"
            hint="请输入医生名称"
            text={getDoctorName()}
            textSize="14" />

        <button id="saveAndStart"
            marginTop="16"
            text="启动测试脚本" />

    </vertical>
);

ui.saveAndStart.click(function () {
    var name = ui.doctor.text();
    if (!name || (name.length < 1)) {
        toast("输入错误!");
        return;
    }

    // 保存本地
    setDoctorName(name)
    setTimeout(() => {
        threads.start(function () {
            //在新线程启动脚本
            main(true);
        });
    }, 1000);
});


function main() {

    /** 程序结束自动 隐藏控制台 */
    console.show(false);
    console.setSize(device.width/4, device.height/4);
    console.setPosition(0, device.height*0.7);

    // 调起微信
    // let pckName = app.getPackageName("微信");
    const pckName = "com.tencent.mm";
    console.log("打开: 微信 App: ", pckName);
    app.launchPackage(pckName)

    console.log("等待10秒");
    sleep(10 * 1000);

    /**
     * 判断是否是西京医院公众号首页
     * 默认出现：医疗服务、便民服务、个人中心、预约挂号
     * 这几个词时，才当为首页
     */
    const isXiJingIndexPage = () => {

        const keyword1 = "医疗服务";
        const keyword2 = "便民服务";
        const keyword3 = "个人中心";
        const keyword4 = "预约挂号";

        for (let i = 0; i < QUERY_TIMES; i++) {
            // 读取当前页面信息
            let textList = className("TextView").find();
            let con1 = false;
            let con2 = false;
            let con3 = false;
            let con4 = false;

            for (let index = 0; index < textList.length; index++) {
                let tv = textList[index];
                let curText = tv.text() || ""
                console.log("isXiJingIndexPage-当前: " + index + ", 内容: " + curText);

                if (curText.indexOf(keyword1) !== -1) {
                    con1 = true;
                } else if (curText.indexOf(keyword2) !== -1) {
                    con2 = true;
                } else if (curText.indexOf(keyword3) !== -1) {
                    con3 = true;
                } else if (curText.indexOf(keyword4) !== -1) {
                    con4 = true;
                }

                if (con1 && con2 && con3 && con4) {
                    console.log("isXiJingIndexPage-当前是西京医院公众号首页");
                    textList.length = 0;
                    textList = null;
                    return true;
                }
            }

            sleep(1000);
        }

        console.log("isXiJingIndexPage-当前不是西京医院公众号首页");
        return false;
    }

    /**
     * 判断是否是就诊声明页
     * 默认出现：就诊声明、我已阅读并同意内容、尊敬的患者朋友
     * 这几个词时，才当为就诊声明页
     */
    const isMedicalDisclaimerPage = () => {

        const keyword1 = "就诊声明";
        const keyword2 = "我已阅读并同意内容";
        const keyword3 = "尊敬的患者朋友";

        for (let i = 0; i < QUERY_TIMES; i++) {
            // 读取当前页面信息
            let textList = className("TextView").find();
            let con1 = false;
            let con2 = false;
            let con3 = false;

            for (let index = 0; index < textList.length; index++) {
                let tv = textList[index];
                let curText = tv.text() || "";
                console.log("isMedicalDisclaimerPage-当前: " + index + ", 内容: " + curText);

                if (curText.indexOf(keyword1) !== -1) {
                    con1 = true;
                } else if (curText === keyword2) {
                    con2 = true;
                } else if (curText.indexOf(keyword3) !== -1) {
                    con3 = true;
                }

                // 等待倒计时结束
                // let regex = /^我已阅读并同意内容.*秒.*/;
                // if (!regex.test(curText)) {
                //     con4 = true;
                // }

                if (con1 && con2 && con3) {
                    console.log("isMedicalDisclaimerPage-当前是就诊声明页");
                    textList.length = 0;
                    textList = null;
                    return true;
                }
            }

            textList.length = 0;
            textList = null;

            sleep(1000);
        }

        console.log("isMedicalDisclaimerPage-当前不是就诊声明页");
        return false;
    }

    /**
     * 判断是否是挂号选择科室页
     * 默认出现：内科、外科、专科、中医、特需、专病
     * 这几个词时，才当为挂号选择科室页
     */
    const isDepartmentSelectionPage = () => {

        const keyword1 = "内科";
        const keyword2 = "外科";
        const keyword3 = "专科";
        const keyword4 = "中医";
        const keyword5 = "特需";
        const keyword6 = "专病";

        for (let i = 0; i < QUERY_TIMES; i++) {
            // 读取当前页面信息
            let textList = className("TextView").find();
            let con1 = false;
            let con2 = false;
            let con3 = false;
            let con4 = false;
            let con5 = false;
            let con6 = false;

            for (let index = 0; index < textList.length; index++) {
                let tv = textList[index];
                let curText = tv.text() || ""
                console.log("isDepartmentSelectionPage-当前: " + index + ", 内容: " + curText);

                if (curText.indexOf(keyword1) !== -1) {
                    con1 = true;
                } else if (curText.indexOf(keyword2) !== -1) {
                    con2 = true;
                } else if (curText.indexOf(keyword3) !== -1) {
                    con3 = true;
                } else if (curText.indexOf(keyword4) !== -1) {
                    con4 = true;
                } else if (curText.indexOf(keyword5) !== -1) {
                    con5 = true;
                } else if (curText.indexOf(keyword6) !== -1) {
                    con6 = true;
                }

                if (con1 && con2 && con3 && con4 && con5 && con6) {
                    console.log("isDepartmentSelectionPage-当前是挂号选择科室页");
                    textList.length = 0;
                    textList = null;
                    return true;
                }
            }

            textList.length = 0;
            textList = null;

            sleep(1000);
        }

        console.log("isDepartmentSelectionPage-当前不是挂号选择科室页");
        return false;
    }

    /**
     * 判断是否是医生搜索成功页
     * 默认出现：{name}、医生信息、医生特长、西京医院 搜索关键词在内的时
     * 才当为搜索成功页
     */
    const isSearchDoctorResultSuccessPage = (name) => {

        const keyword1 = "医生信息";
        const keyword2 = "西京医院";
        const keyword3 = "医生特长";

        for (let i = 0; i < QUERY_TIMES; i++) {
            // 读取当前页面信息
            let textList = className("TextView").find();
            let con1 = false;
            let con2 = false;
            let con3 = false;
            let con4 = false;

            for (let index = 0; index < textList.length; index++) {
                let tv = textList[index];
                let curText = tv.text() || ""
                console.log("isSearchDoctorResultSuccessPage-当前: " + index + ", 内容: " + curText);

                if (curText.indexOf(name) !== -1) {
                    console.log("isSearchDoctorResultSuccessPage-找到name");
                    con1 = true;
                }
                if (curText.indexOf(keyword1) !== -1) {
                    con2 = true;
                }
                if (curText.indexOf(keyword2) !== -1) {
                    con3 = true;
                }
                if (curText.indexOf(keyword3) !== -1) {
                    con4 = true;
                }

                if (con1 && con2 && con3 && con4) {
                    console.log("isSearchDoctorResultSuccessPage-当前是医生搜索成功页");
                    textList.length = 0;
                    textList = null;
                    return true;
                }
            }

            textList.length = 0;
            textList = null;

            sleep(1000);
        }

        console.log("isSearchDoctorResultSuccessPage-当前不是医生搜索成功页");
        return false;
    }

    /**
     * 判断是否是医生主页
     * 默认出现：{name}、医生主页、累计挂号量、西京医院、出诊信息、简介、全部、日期 搜索关键词在内的时
     * 才当为医生主页
     */
    const isDoctorIndexPage = (name) => {

        const keyword1 = "医生主页";
        const keyword2 = "西京医院";
        // const keyword3 = "累计挂号量";
        // const keyword4 = "出诊信息";
        // const keyword5 = "简介";
        // const keyword6 = "全部";
        // const keyword7 = "日期";

        for (let i = 0; i < QUERY_TIMES; i++) {
            // 读取当前页面信息
            let textList = className("TextView").find();
            let con1 = false;
            let con2 = false;
            // let con3 = false;
            // let con4 = false;
            // let con5 = false;
            // let con6 = false;
            // let con7 = false;
            // let con8 = false;

            for (let index = 0; index < textList.length; index++) {
                let tv = textList[index];
                let curText = tv.text() || ""
                console.log("isDoctorIndexPage-当前: " + index + ", 内容: " + curText);

                if (curText.indexOf(keyword1) !== -1) {
                    con1 = true;
                }
                if (curText.indexOf(keyword2) !== -1) {
                    con2 = true;
                }

                // if (curText.indexOf(name) !== -1) {
                //     con1 = true;
                // }
                // if (curText.indexOf(keyword1) !== -1) {
                //     con2 = true;
                // }
                // if (curText.indexOf(keyword2) !== -1) {
                //     con3 = true;
                // }
                // if (curText.indexOf(keyword3) !== -1) {
                //     con4 = true;
                // }
                // if (curText.indexOf(keyword4) !== -1) {
                //     con5 = true;
                // }
                // if (curText.indexOf(keyword5) !== -1) {
                //     con6 = true;
                // }
                // if (curText.indexOf(keyword6) !== -1) {
                //     con7 = true;
                // }
                // if (curText.indexOf(keyword7) !== -1) {
                //     con8 = true;
                // }

                if (con1 && con2) {
                    console.log("isDoctorIndexPage-当前是医生首页");
                    textList.length = 0;
                    textList = null;
                    return true;
                }
            }

            textList.length = 0;
            textList = null;

            sleep(1000);
        }

        console.log("isDoctorIndexPage-当前不是医生首页");
        return false;
    }

    /**
     * 判断医生是否有号
     * 默认出现：{name}、有号、余 搜索关键词在内的时
     * 才当为有号依据  1240
     */
    const isDoctorCanAppointment = (name) => {

        const keyword1 = "有号";
        const keyword2 = "全部";
        const keyword3 = "日期";

        click(device.width * 0.85, 730);
        sleep(1000);
        click(device.width * 0.25, 730);
        sleep(1000);

        for (let i = 0; i < QUERY_TIMES; i++) {
            // 读取当前页面信息
            let textList = className("TextView").find();
            let con1 = false;
            let con2 = false;
            let con3 = false;
            let con4 = false;

            for (let index = 0; index < textList.length; index++) {
                let tv = textList[index];
                let curText = tv.text() || ""
                console.log("isDoctorCanAppointment-当前: " + index + ", 内容: " + curText);

                if (curText.indexOf(keyword1) !== -1) {
                    con1 = true;
                }
                if (curText.indexOf(keyword2) !== -1) {
                    con2 = true;
                }
                if (curText.indexOf(keyword3) !== -1) {
                    con3 = true;
                }

                // if (curText.indexOf(name) !== -1) {
                //     con1 = true;
                // }
                // if (curText.indexOf(keyword1) !== -1) {
                //     con2 = true;
                // }
                // if (curText.indexOf(keyword2) !== -1) {
                //     con3 = true;
                // }
                // if (curText.indexOf(keyword3) !== -1) {
                //     con4 = true;
                // }

                if (con1 && con2 && con3) {
                    console.log("isDoctorCanAppointment-当前医生有号");
                    textList.length = 0;
                    textList = null;
                    return true;
                }
            }

            textList.length = 0;
            textList = null;

            // 读取当前页面信息
            const keyword4 = "余 ";
            let buttonList = className("Button").find();
            for (let index = 0; index < buttonList.length; index++) {
                let tv = buttonList[index];
                let curText = tv.text() || ""
                console.log("isDoctorCanAppointment-当前-btn: " + index + ", 内容: " + curText);

                if (curText.indexOf(keyword4) !== -1) {
                    console.log("isDoctorCanAppointment-当前医生有号");
                    buttonList.length = 0;
                    buttonList = null;
                    return true;
                }
            }

            sleep(1000);
        }

        console.log("isDoctorCanAppointment-当前医生无号");
        return false;
    }

    /**
     * 判断是否是挂号须知页
     * 默认出现：挂号须知、我已阅读并同意、不同意
     * 这几个词时，才当为就诊声明页
     */
    const isAppointmentDisclaimerPage = () => {

        const keyword1 = "挂号须知";
        // const keyword2 = "我已阅读并同意";
        // const keyword3 = "不同意";
        // const keyword4 = "温馨提示";

        for (let i = 0; i < QUERY_TIMES; i++) {
            // 读取当前页面信息
            let textList = className("TextView").find();
            let con1 = false;
            // let con2 = false;
            // let con3 = false;
            // let con4 = false;

            for (let index = 0; index < textList.length; index++) {
                let tv = textList[index];
                let curText = tv.text() || ""
                console.log("isAppointmentDisclaimerPage-当前: " + index + ", 内容: " + curText);

                if (curText.indexOf(keyword1) !== -1) {
                    con1 = true;
                }
                // if (curText === keyword2) {
                //     con2 = true;
                // }
                // if (curText.indexOf(keyword3) !== -1) {
                //     con3 = true;
                // }
                // if (curText.indexOf(keyword4) !== -1) {
                //     con4 = true;
                // }

                if (con1) {
                    console.log("isAppointmentDisclaimerPage-当前是挂号须知页");
                    textList.length = 0;
                    textList = null;
                    return true;
                }
            }

            textList.length = 0;
            textList = null;

            sleep(1000);
        }

        console.log("isAppointmentDisclaimerPage-当前不是挂号须知页");
        return false;
    }

    /**
     * 判断是否是挂号选择时间页
     * 默认出现：{name} 就诊院区、就诊日期、诊查费、就诊人、支付类型、预约时间段、余 、确定
     * 这几个词时，才当为挂号选择时间页
     */
    const isAppointmentSelectDatePage = (name) => {

        const keyword1 = "诊查费";
        const keyword2 = "预约时间段";
        // const keyword3 = "诊查费";
        // const keyword4 = "就诊人";
        // const keyword5 = "支付类型";
        // const keyword6 = "预约时间段";
        // const keyword7 = "余 ";
        // const keyword8 = "确定";

        for (let i = 0; i < QUERY_TIMES; i++) {
            // 读取当前页面信息
            let textList = className("TextView").find();
            let con1 = false;
            let con2 = false;
            // let con3 = false;
            // let con4 = false;
            // let con5 = false;
            // let con6 = false;
            // let con7 = false;
            // let con8 = false;
            // let con9 = false;

            for (let index = 0; index < textList.length; index++) {
                let tv = textList[index];
                let curText = tv.text() || ""
                console.log("isAppointmentSelectDatePage-当前: " + index + ", 内容: " + curText);

                if (curText.indexOf(keyword1) !== -1) {
                    con1 = true;
                }
                if (curText.indexOf(keyword2) !== -1) {
                    con2 = true;
                }
                // if (curText === name) {
                //     con3 = true;
                // }
                // if (curText.indexOf(keyword3) !== -1) {
                //     con4 = true;
                // }
                // if (curText.indexOf(keyword4) !== -1) {
                //     con5 = true;
                // }
                // if (curText.indexOf(keyword5) !== -1) {
                //     con6 = true;
                // }
                // if (curText.indexOf(keyword6) !== -1) {
                //     con7 = true;
                // }
                // if (curText.indexOf(keyword7) !== -1) {
                //     con8 = true;
                // }
                // if (curText.indexOf(keyword8) !== -1) {
                //     con9 = true;
                // }

                if (con1 && con2) {
                    console.log("isAppointmentSelectDatePage-当前是挂号选择时间页");
                    textList.length = 0;
                    textList = null;
                    return true;
                }
            }

            textList.length = 0;
            textList = null;

            sleep(1000);
        }

        console.log("isAppointmentSelectDatePage-当前不是挂号选择时间页");
        return false;
    }

    /**
     * 判断是否是挂号成功待支付页
     * 默认出现：微信支付、请输入支付密码、立即支付
     * 这几个词时，才当为挂号成功待支付页
     */
    const isWaitingPaymentPage = (name) => {

        const keyword1 = "请输入支付密码";

        for (let i = 0; i < QUERY_TIMES; i++) {
            // 读取当前页面信息
            let textList = className("TextView").find();
            let con1 = false;

            for (let index = 0; index < textList.length; index++) {
                let tv = textList[index];
                let curText = tv.text() || ""
                console.log("isWaitingPaymentPage-当前: " + index + ", 内容: " + curText);

                if (curText.indexOf(keyword1) !== -1) {
                    con1 = true;
                }

                if (con1) {
                    console.log("isWaitingPaymentPage-当前是挂号成功待支付页");
                    textList.length = 0;
                    textList = null;
                    return true;
                }
            }

            textList.length = 0;
            textList = null;

            sleep(1000);
        }

        console.log("isWaitingPaymentPage-当前不是挂号成功待支付页");
        return false;
    }

    /**
     * 首页-点击-预约挂号
     */
    const clickAppointment = () => {
        let word = "预约挂号";
        click(word);
        sleep(500);
        return true;
    }

    /**
     * 就诊声明页-点击-我已阅读并同意内容
     */
    const clickAgreeStatement = () => {
        let word = "我已阅读并同意内容";
        click(word);
        sleep(500);
        return true;
    }

    /**
     * 科室选择页-点击-搜索
     */
    const clickSearchDoctorBar = () => {
        click(device.width * 0.8, 310);
        sleep(1000);
        return true;
    }

    /**
     * 搜索页-输入医生名称
     */
    const inputSearchDoctorName = (name) => {
        // 输入名称
        let input = className("EditText").findOnce();
        if (input === null) {
            return false;
        }
        input.setText(name);

        // 弹起键盘-点击搜索
        click(device.width * 0.7, 310);
        sleep(1000);
        click(device.width * 0.9, device.height * 0.9);
        sleep(500);
        // 收起键盘
        click(device.width * 0.9, 420);

        sleep(1000);
        return true;
    }

    /**
     * 搜索结果页-点击第1条记录
     */
    const clickSearchResultFirst = (name) => {
        // click(name);
        click(device.width * 0.85, 860);
        sleep(1000);
        return true;
    }

    /**
     * 医生主页-点击有号并进行预约
     */
    const clickDoctorAppointment = () => {
        let keyword1 = "有号";
        let keyword2 = "余 ";

        click(keyword1);
        sleep(500);

        let buttonList = className("Button").find();
        for (let index = 0; index < buttonList.length; index++) {
            let tv = buttonList[index];
            let curText = tv.text() || ""
            console.log("clickDoctorAppointment-当前-btn: " + index + ", 内容: " + curText);
            if (curText.indexOf(keyword2) !== -1) {
                let curY = curText.bounds().centerY();
                click(device.width * 0.9, curY);
                sleep(500);
                buttonList.length = 0;
                buttonList = null;
                return true;
            }
        }

        click(device.width * 0.9, 1240);
        sleep(500);
        buttonList.length = 0;
        buttonList = null;
        return true;
    }

    /**
     * 挂号须知页-点击-我已阅读并同意
     */
    const clickAgreeAppointment = () => {
        sleep(4000);
        let keyword = "我已阅读并同意";
        click(keyword);
        sleep(500);

        click(device.width * 0.93, device.height * 0.9);
        sleep(500);

        click(device.width * 0.93, device.height * 0.98);
        sleep(500);

        return true;
    }

    /**
     * 挂号选择时间页-点击-确定
     */
    const clickAppointmentDateConfirm = () => {
        // let keyword = "确定";
        // click(keyword);
        // sleep(1000);
        // click(keyword);
        // sleep(1000);
        click(device.width * 0.93, device.height * 0.9);
        sleep(500);

        click(device.width * 0.93, device.height * 0.98);
        sleep(500);

        click(device.width * 0.93, device.height * 0.9);
        sleep(500);

        click(device.width * 0.93, device.height * 0.98);
        sleep(500);

        click(device.width * 0.93, device.height * 0.9);
        sleep(500);

        click(device.width * 0.93, device.height * 0.98);
        sleep(500);

        click(device.width * 0.93, device.height * 0.9);
        sleep(500);

        click(device.width * 0.93, device.height * 0.98);
        sleep(500);

        click(device.width * 0.93, device.height * 0.9);
        sleep(500);

        click(device.width * 0.93, device.height * 0.98);
        sleep(500);

        click(device.width * 0.93, device.height * 0.9);
        sleep(500);

        click(device.width * 0.93, device.height * 0.98);
        sleep(500);

        click(device.width * 0.93, device.height * 0.9);
        sleep(500);

        click(device.width * 0.93, device.height * 0.98);
        sleep(500);

        click(device.width * 0.93, device.height * 0.9);
        sleep(500);

        click(device.width * 0.93, device.height * 0.98);
        sleep(500);
        return true;
    }

    /**
     * 挂号选择时间页-已下单-取消自动支付，去手动支付
     */
    const clickClosePayment = () => {
        back();
        sleep(500);
        click(60, 170);
        sleep(1000);
        console.log("clickClosePayment-当前挂号成功，待手动支付");
        return true;
    }

    // 循环执行
    let doctorName = getDoctorName();
    let needLoop = true;
    while (needLoop) {
        /** 只有要首页匹配成功才执行 */
        if (isXiJingIndexPage()) {

            // 点击预约挂号
            let clickAppointmentResult = clickAppointment();
            if (clickAppointmentResult) {

                // 进入就诊声明
                let isMedicalDisclaimerPageResult = isMedicalDisclaimerPage();
                if (isMedicalDisclaimerPageResult) {

                    // 点击同意声明内容
                    let clickAgreeStatementResult = clickAgreeStatement();
                    if (clickAgreeStatementResult) {

                        // 进入科室选择页
                        let isDepartmentSelectionPageResult = isDepartmentSelectionPage();
                        if (isDepartmentSelectionPageResult) {

                            // 点击输入医生名
                            let clickSearchDoctorBarResult = clickSearchDoctorBar();
                            if (clickSearchDoctorBarResult) {

                                // 搜索医生
                                let inputSearchDoctorNameResult = inputSearchDoctorName(doctorName);
                                if (inputSearchDoctorNameResult) {

                                    // 等待搜索结果
                                    let isSearchDoctorResultSuccessPageResult = isSearchDoctorResultSuccessPage(doctorName);
                                    if (isSearchDoctorResultSuccessPageResult) {

                                        // 点击第1条搜索结果
                                        let clickSearchResultFirstResult = clickSearchResultFirst(doctorName);
                                        if (clickSearchResultFirstResult) {

                                            // 进入医生首页
                                            let isDoctorIndexPageResult = isDoctorIndexPage(doctorName);
                                            if (isDoctorIndexPageResult) {

                                                // 判断医生是否有号
                                                let isDoctorCanAppointmentResult = isDoctorCanAppointment(doctorName);
                                                if (isDoctorCanAppointmentResult) {

                                                    // 点击有号并进行预约
                                                    let clickDoctorAppointmentResult = clickDoctorAppointment(doctorName);
                                                    if (clickDoctorAppointmentResult) {

                                                        // 进入挂号须知页
                                                        let isAppointmentDisclaimerPageResult = isAppointmentDisclaimerPage();
                                                        if (isAppointmentDisclaimerPageResult) {

                                                            // 点击同意挂号
                                                            let clickAgreeAppointmentResult = clickAgreeAppointment();
                                                            if (clickAgreeAppointmentResult) {

                                                                // 进入挂号选择时间页
                                                                let isAppointmentSelectDatePageResult = isAppointmentSelectDatePage();
                                                                if (isAppointmentSelectDatePageResult) {

                                                                    // 默认选择当前最早时间 
                                                                    let clickAppointmentDateConfirmResult = clickAppointmentDateConfirm();
                                                                    if (clickAppointmentDateConfirmResult) {

                                                                        // 挂号成功，关闭自动支付，待手支动支付
                                                                        let isWaitingPaymentPageResult = isWaitingPaymentPage();
                                                                        if (isWaitingPaymentPageResult) {
                                                                            clickClosePayment();
                                                                            needLoop = false;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // let closeBtn = id("com.tencent.mm:id/actionbar_up_indicator_btn").findOnce();
        // if (closeBtn != null) {
        //     closeBtn.click();
        // }
        click(60, 170);
        sleep(1500);
    }
}